from fastapi import APIRouter
from utils.tools import logger
from utils.response_util import response_200, response_500
from app.module.entity.vo.task_state_vo import TaskStatusModel
from app.funcs import choice_book

chatatController = APIRouter()

@chatatController.post("/choice_book")
def choice_book_api(book:str):
    if not book.endswith('.txt'):
        book = book + '.txt'
    # 查询book是否存在
    async_result = choice_book.push(book)
    logger.debug(f"返回taskid给前端： [{async_result.task_id}]")
    model = TaskStatusModel(task_id=async_result.task_id)
    return response_200(data=model, message="提交成功") 